//---------------------------------------------------------------------------

#ifndef TStatisticsFormH
#define TStatisticsFormH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
#include <ExtCtrls.hpp>
#include <Grids.hpp>
#include <ToolWin.hpp>
#include "Chart.hpp"
#include "Series.hpp"
#include "TeEngine.hpp"
#include "TeeProcs.hpp"
//#include "SysUtils.hpp"
#include "tlhelp32.h"

//#include "Excel_TLB.h"

#include "TCut.h"
#include "CoFunction.h"
#include "TStatistics.h"
#include "TDrawCheckMap.h"
#include <ImgList.hpp>
#include <OleServer.hpp>
#include "TWriteAVI.h"
//#include "Excel_XP_srvr.h"
#include "TAVIFileParameterForm.h"
#include "AdvGrid.hpp"
#include "BaseGrid.hpp"
#include "AdvListV.hpp"
#include "tmsAdvGridExcel.hpp"
#include "AdvGridWorkbook.hpp"
#include "AdvObj.hpp"

#define PG OlePropertyGet
#define PS OlePropertySet
#define FN OleFunction
#define PR OleProcedure
//  */
enum TStatisticsResultIndex {SwitchTime = 1, Cut, CtrRetarderSametimeQuantity,
									  BoostSametimeQuantity, CtrRetarderUtilization,
									  RetarderUtilization, ArresterUtilization};
//---------------------------------------------------------------------------
class TStatisticsIndex
{
public:
	int Index;
	AnsiString Name;
	bool IsToExcel;
};

//---------------------------------------------------------------------------
class TStatIndex : public vector<TStatisticsIndex>
{
public:
	void __fastcall Add(const int Index, const AnsiString Name, const bool IsToExcel = true);
	void __fastcall Initialize(void);
	AnsiString __fastcall GetName(const int Index);
};

//---------------------------------------------------------------------------
class TStatisticsForm : public TForm
{
__published:	// IDE-managed Components
	TTreeView *TreeView1;
	TSplitter *Splitter1;
	TToolBar *ToolBar1;
	TPageControl *PageControl1;
	TTabSheet *CutStatisticTabSheet;
	TTabSheet *ControlStatisticTabSheet;
	TChart *CtrRetarderChart;
	TBarSeries *Series1;
	TTabSheet *BoostStatisticsTabSheet;
	TChart *BoostChart;
	TBarSeries *Series2;
	THeaderControl *HeaderControl1;
	TListView *StatListView;
	TImageList *ImageList1;
	TToolButton *ToolButton4;
	TToolButton *ExitToolButton;
	TToolButton *ExportSingleItemToolButton;
	TToolButton *ExportAllItemsToolButton;
	TToolButton *ExportAVIToolButton;
	TAdvGridExcelIO *AdvGridExcelIO1;
	TAdvGridWorkbook *StatisticsAdvGridWorkbook;
	TAdvStringGrid *AdvStringGrid1;
	void __fastcall TreeView1Click(TObject *Sender);
	void __fastcall ExitToolButtonClick(TObject *Sender);
	void __fastcall ExportSingleItemToolButtonClick(TObject *Sender);
	void __fastcall ExportAllItemsToolButtonClick(TObject *Sender);
	void __fastcall ExportAVIToolButtonClick(TObject *Sender);

private:	// User declarations
	TStatIndex StatIndex;
	bool __fastcall ExcelAppIsRun(void);
	void __fastcall ShowCaption(const AnsiString Caption);
	AnsiString __fastcall SetExcelFileName(const AnsiString ProjectFileName, const int ExcelVersion);
public:		// User declarations
	TStatistics *Statistics;
	TDrawCheckMap *DrawCheckMap;
	AnsiString ProjectFileName;
	__fastcall TStatisticsForm(TComponent* Owner);
	void __fastcall ShowStatistics(void);
	void __fastcall ExportSingleStaitisticsResultOLE(void);
	void __fastcall ExportAllStatisticsResultOLE(void);
};
//---------------------------------------------------------------------------
extern PACKAGE TStatisticsForm *StatisticsForm;
//---------------------------------------------------------------------------
#endif
